local uri_args = ngx.req.get_uri_args()
local productId = uri_args["productId"]

local hosts = {"156.70.0.3", "156.70.0.4"}

local hash = ngx.crc32_long(productId)
local index = (hash % 2) + 1  
local backend = "http://"..hosts[index]

local requestPath = uri_args["requestPath"]
local requestBody = "/"..requestPath.."?productId="..productId

local http = require("resty.http")  
local httpc = http.new()

local resp, err = httpc:request_uri(backend, {  
    method = "GET",  
    path = requestBody
})

if not resp then  
    ngx.say("request error :", err)  
    return  
end

ngx.say(resp.body)

httpc:close()